/*
 * YouRlayer - The best music player on Sony PSP
 * Copyright (C) 2009 Umin (umin90@gmail.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
#include "config.h"

char *IniStr;
FILE *file;
int isInit=0;

void init(){
    extern config;
    char lanPath[]="Languages/english.lan";
    char skinPath[]="Skins/default/";
    
    config.sys.brighteness = 60;
    config.sys.language = (char*)malloc(sizeof(lanPath));
    config.sys.language = lanPath;
    config.sys.screenAlwaysLight = 1;
    config.sys.powerSavingModeType = 0;
    config.sys.normalCpu = 222;
    config.sys.savingCpu = 80;
    
    config.usr.lastList = "";
    config.usr.skinPath = (char*)malloc(sizeof(skinPath));
    config.usr.skinPath = "";
}

void Ini_open(const char *path){
    int len;
    char tmp[512];
    FILE *file;
    file=fopen(path,"r");
    fseek(file,SEEK_END);
    len=ftell(file);
    fseek(file,SEEK_SET);
    fread(&tmp,len,1,path);
    fclose(file);
    isInit=1;
    sift(tmp,0x20);
    sift(tmp,0);
    IniStr=(char*)malloc(sizeof(tmp));
    strcpy(IniStr,tmp);
    init();
}

char *Ini_readStr(const char *class,const char *label){
    if(!isInit)error("Must open a ini file before use.");
    
    char *p;
    int re;
    char *tmp;
    int labelLen=strlen(label),classLen=strlen(class);
    int labelPos,elen;
    char *ep;
    
    p=strstr(p,class)+classLen+3;
    labelPos=strstr(p,label);
    p=labelPos+labelLen+2;
    ep=strchr(p,'\n');
    elen=(ep-p)+1;
    tmp=(char*)malloc(elen);
    strcpy(tmp,ep)
    tmp[elen]=0;
    return tmp;
}

/*
int Ini_readNum(const char *class,const char *label){
    if(!isInit)error("Must open a ini file before use.");
    
    char *p;
    int re;
    char *tmp;
    int labelLen=strlen(label),classLen=strlen(class);
    int labelPos,elen;
    char* ep;
    
    p=strstr(p,class)+classLen+3;
    labelPos=strstr(p,label);
    p=labelPos+labelLen+2;
    ep=strchr(p,'\n');
    elen=(ep-p)+1;
    tmp=(char*)malloc(elen);
    strcpy(tmp,ep)
    tmp[elen]=0;
    return toNumber(tmp);
}
*/

void Ini_term(){
    free(IniStr);
    isInit=0;
}

